package com.jt.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.ItemParamMapper;
import com.jt.pojo.ItemParam;
import com.jt.service.ItemParamService;
import com.jt.utils.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dc
 * @Classname ItemParamServiceImpl
 * @Date 2020/3/22 9:52
 */
@Service
public class ItemParamServiceImpl implements ItemParamService {
    @Autowired
    ItemParamMapper itemParamMapper;

    @Override
    public ItemParam getItemParamByItemId(Long itemId) {
        //根据商品id查询规格参数
        QueryWrapper<ItemParam> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("item_id",itemId);
        ItemParam itemParam = itemParamMapper.selectOne(queryWrapper);
        Assert.isServiceValid(itemParam==null,"查询商品的规格参数不存在!");
        return itemParam;
    }
}
